<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>剩余参数获得多余的实参</title>
</head>

<body>
  <script>
    // ============================== 剩余参数 ==============================
    // 1. 剩余参数获得多余的实参 是个真数组

    // function getSum(x, y, z) {
    //   console.log(x, y, z)
    // }
    // getSum(10, 20, 30, 40, 50, 60, 70)



    // 2. 收集所有实参
    // function getSum(...z) {
    //   console.log(z)
    // }
    // getSum(10, 20, 30, 40, 50, 60, 70)



    // 3. 注意事项：剩余参数必须是最后一个参数
    function getSum(x, y, ...z) {
      console.log(x, y, z)
    }
    getSum(10, 20, 30, 40, 50, 60, 70)

  </script>
</body>

</html>